/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
/**
 * Autogenerated by Thrift Compiler (0.15.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.pinot.common.request;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)", date = "2024-05-01")
public class PinotQuery implements org.apache.thrift.TBase<PinotQuery, PinotQuery._Fields>, java.io.Serializable, Cloneable, Comparable<PinotQuery> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PinotQuery");

  private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.I32, (short)1);
  private static final org.apache.thrift.protocol.TField DATA_SOURCE_FIELD_DESC = new org.apache.thrift.protocol.TField("dataSource", org.apache.thrift.protocol.TType.STRUCT, (short)2);
  private static final org.apache.thrift.protocol.TField SELECT_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("selectList", org.apache.thrift.protocol.TType.LIST, (short)3);
  private static final org.apache.thrift.protocol.TField FILTER_EXPRESSION_FIELD_DESC = new org.apache.thrift.protocol.TField("filterExpression", org.apache.thrift.protocol.TType.STRUCT, (short)4);
  private static final org.apache.thrift.protocol.TField GROUP_BY_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("groupByList", org.apache.thrift.protocol.TType.LIST, (short)5);
  private static final org.apache.thrift.protocol.TField ORDER_BY_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("orderByList", org.apache.thrift.protocol.TType.LIST, (short)6);
  private static final org.apache.thrift.protocol.TField HAVING_EXPRESSION_FIELD_DESC = new org.apache.thrift.protocol.TField("havingExpression", org.apache.thrift.protocol.TType.STRUCT, (short)7);
  private static final org.apache.thrift.protocol.TField LIMIT_FIELD_DESC = new org.apache.thrift.protocol.TField("limit", org.apache.thrift.protocol.TType.I32, (short)8);
  private static final org.apache.thrift.protocol.TField OFFSET_FIELD_DESC = new org.apache.thrift.protocol.TField("offset", org.apache.thrift.protocol.TType.I32, (short)9);
  private static final org.apache.thrift.protocol.TField QUERY_OPTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("queryOptions", org.apache.thrift.protocol.TType.MAP, (short)11);
  private static final org.apache.thrift.protocol.TField EXPLAIN_FIELD_DESC = new org.apache.thrift.protocol.TField("explain", org.apache.thrift.protocol.TType.BOOL, (short)12);
  private static final org.apache.thrift.protocol.TField EXPRESSION_OVERRIDE_HINTS_FIELD_DESC = new org.apache.thrift.protocol.TField("expressionOverrideHints", org.apache.thrift.protocol.TType.MAP, (short)13);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new PinotQueryStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new PinotQueryTupleSchemeFactory();

  private int version; // optional
  private @org.apache.thrift.annotation.Nullable DataSource dataSource; // optional
  private @org.apache.thrift.annotation.Nullable java.util.List<Expression> selectList; // optional
  private @org.apache.thrift.annotation.Nullable Expression filterExpression; // optional
  private @org.apache.thrift.annotation.Nullable java.util.List<Expression> groupByList; // optional
  private @org.apache.thrift.annotation.Nullable java.util.List<Expression> orderByList; // optional
  private @org.apache.thrift.annotation.Nullable Expression havingExpression; // optional
  private int limit; // optional
  private int offset; // optional
  private @org.apache.thrift.annotation.Nullable java.util.Map<java.lang.String,java.lang.String> queryOptions; // optional
  private boolean explain; // optional
  private @org.apache.thrift.annotation.Nullable java.util.Map<Expression,Expression> expressionOverrideHints; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    VERSION((short)1, "version"),
    DATA_SOURCE((short)2, "dataSource"),
    SELECT_LIST((short)3, "selectList"),
    FILTER_EXPRESSION((short)4, "filterExpression"),
    GROUP_BY_LIST((short)5, "groupByList"),
    ORDER_BY_LIST((short)6, "orderByList"),
    HAVING_EXPRESSION((short)7, "havingExpression"),
    LIMIT((short)8, "limit"),
    OFFSET((short)9, "offset"),
    QUERY_OPTIONS((short)11, "queryOptions"),
    EXPLAIN((short)12, "explain"),
    EXPRESSION_OVERRIDE_HINTS((short)13, "expressionOverrideHints");

    private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

    static {
      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // VERSION
          return VERSION;
        case 2: // DATA_SOURCE
          return DATA_SOURCE;
        case 3: // SELECT_LIST
          return SELECT_LIST;
        case 4: // FILTER_EXPRESSION
          return FILTER_EXPRESSION;
        case 5: // GROUP_BY_LIST
          return GROUP_BY_LIST;
        case 6: // ORDER_BY_LIST
          return ORDER_BY_LIST;
        case 7: // HAVING_EXPRESSION
          return HAVING_EXPRESSION;
        case 8: // LIMIT
          return LIMIT;
        case 9: // OFFSET
          return OFFSET;
        case 11: // QUERY_OPTIONS
          return QUERY_OPTIONS;
        case 12: // EXPLAIN
          return EXPLAIN;
        case 13: // EXPRESSION_OVERRIDE_HINTS
          return EXPRESSION_OVERRIDE_HINTS;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

    _Fields(short thriftId, java.lang.String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __VERSION_ISSET_ID = 0;
  private static final int __LIMIT_ISSET_ID = 1;
  private static final int __OFFSET_ISSET_ID = 2;
  private static final int __EXPLAIN_ISSET_ID = 3;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.VERSION,_Fields.DATA_SOURCE,_Fields.SELECT_LIST,_Fields.FILTER_EXPRESSION,_Fields.GROUP_BY_LIST,_Fields.ORDER_BY_LIST,_Fields.HAVING_EXPRESSION,_Fields.LIMIT,_Fields.OFFSET,_Fields.QUERY_OPTIONS,_Fields.EXPLAIN,_Fields.EXPRESSION_OVERRIDE_HINTS};
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.DATA_SOURCE, new org.apache.thrift.meta_data.FieldMetaData("dataSource", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT        , "DataSource")));
    tmpMap.put(_Fields.SELECT_LIST, new org.apache.thrift.meta_data.FieldMetaData("selectList", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT            , "Expression"))));
    tmpMap.put(_Fields.FILTER_EXPRESSION, new org.apache.thrift.meta_data.FieldMetaData("filterExpression", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT        , "Expression")));
    tmpMap.put(_Fields.GROUP_BY_LIST, new org.apache.thrift.meta_data.FieldMetaData("groupByList", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT            , "Expression"))));
    tmpMap.put(_Fields.ORDER_BY_LIST, new org.apache.thrift.meta_data.FieldMetaData("orderByList", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT            , "Expression"))));
    tmpMap.put(_Fields.HAVING_EXPRESSION, new org.apache.thrift.meta_data.FieldMetaData("havingExpression", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT        , "Expression")));
    tmpMap.put(_Fields.LIMIT, new org.apache.thrift.meta_data.FieldMetaData("limit", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.OFFSET, new org.apache.thrift.meta_data.FieldMetaData("offset", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.QUERY_OPTIONS, new org.apache.thrift.meta_data.FieldMetaData("queryOptions", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
    tmpMap.put(_Fields.EXPLAIN, new org.apache.thrift.meta_data.FieldMetaData("explain", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.EXPRESSION_OVERRIDE_HINTS, new org.apache.thrift.meta_data.FieldMetaData("expressionOverrideHints", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT            , "Expression"), 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT            , "Expression"))));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PinotQuery.class, metaDataMap);
  }

  public PinotQuery() {
    this.limit = 10;

    this.offset = 0;

  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public PinotQuery(PinotQuery other) {
    __isset_bitfield = other.__isset_bitfield;
    this.version = other.version;
    if (other.isSetDataSource()) {
      this.dataSource = new DataSource(other.dataSource);
    }
    if (other.isSetSelectList()) {
      java.util.List<Expression> __this__selectList = new java.util.ArrayList<Expression>(other.selectList.size());
      for (Expression other_element : other.selectList) {
        __this__selectList.add(new Expression(other_element));
      }
      this.selectList = __this__selectList;
    }
    if (other.isSetFilterExpression()) {
      this.filterExpression = new Expression(other.filterExpression);
    }
    if (other.isSetGroupByList()) {
      java.util.List<Expression> __this__groupByList = new java.util.ArrayList<Expression>(other.groupByList.size());
      for (Expression other_element : other.groupByList) {
        __this__groupByList.add(new Expression(other_element));
      }
      this.groupByList = __this__groupByList;
    }
    if (other.isSetOrderByList()) {
      java.util.List<Expression> __this__orderByList = new java.util.ArrayList<Expression>(other.orderByList.size());
      for (Expression other_element : other.orderByList) {
        __this__orderByList.add(new Expression(other_element));
      }
      this.orderByList = __this__orderByList;
    }
    if (other.isSetHavingExpression()) {
      this.havingExpression = new Expression(other.havingExpression);
    }
    this.limit = other.limit;
    this.offset = other.offset;
    if (other.isSetQueryOptions()) {
      java.util.Map<java.lang.String,java.lang.String> __this__queryOptions = new java.util.HashMap<java.lang.String,java.lang.String>(other.queryOptions);
      this.queryOptions = __this__queryOptions;
    }
    this.explain = other.explain;
    if (other.isSetExpressionOverrideHints()) {
      java.util.Map<Expression,Expression> __this__expressionOverrideHints = new java.util.HashMap<Expression,Expression>(other.expressionOverrideHints.size());
      for (java.util.Map.Entry<Expression, Expression> other_element : other.expressionOverrideHints.entrySet()) {

        Expression other_element_key = other_element.getKey();
        Expression other_element_value = other_element.getValue();

        Expression __this__expressionOverrideHints_copy_key = new Expression(other_element_key);

        Expression __this__expressionOverrideHints_copy_value = new Expression(other_element_value);

        __this__expressionOverrideHints.put(__this__expressionOverrideHints_copy_key, __this__expressionOverrideHints_copy_value);
      }
      this.expressionOverrideHints = __this__expressionOverrideHints;
    }
  }

  public PinotQuery deepCopy() {
    return new PinotQuery(this);
  }

  @Override
  public void clear() {
    setVersionIsSet(false);
    this.version = 0;
    this.dataSource = null;
    this.selectList = null;
    this.filterExpression = null;
    this.groupByList = null;
    this.orderByList = null;
    this.havingExpression = null;
    this.limit = 10;

    this.offset = 0;

    this.queryOptions = null;
    setExplainIsSet(false);
    this.explain = false;
    this.expressionOverrideHints = null;
  }

  public int getVersion() {
    return this.version;
  }

  public void setVersion(int version) {
    this.version = version;
    setVersionIsSet(true);
  }

  public void unsetVersion() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __VERSION_ISSET_ID);
  }

  /** Returns true if field version is set (has been assigned a value) and false otherwise */
  public boolean isSetVersion() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __VERSION_ISSET_ID);
  }

  public void setVersionIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __VERSION_ISSET_ID, value);
  }

  @org.apache.thrift.annotation.Nullable
  public DataSource getDataSource() {
    return this.dataSource;
  }

  public void setDataSource(@org.apache.thrift.annotation.Nullable DataSource dataSource) {
    this.dataSource = dataSource;
  }

  public void unsetDataSource() {
    this.dataSource = null;
  }

  /** Returns true if field dataSource is set (has been assigned a value) and false otherwise */
  public boolean isSetDataSource() {
    return this.dataSource != null;
  }

  public void setDataSourceIsSet(boolean value) {
    if (!value) {
      this.dataSource = null;
    }
  }

  public int getSelectListSize() {
    return (this.selectList == null) ? 0 : this.selectList.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<Expression> getSelectListIterator() {
    return (this.selectList == null) ? null : this.selectList.iterator();
  }

  public void addToSelectList(Expression elem) {
    if (this.selectList == null) {
      this.selectList = new java.util.ArrayList<Expression>();
    }
    this.selectList.add(elem);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.List<Expression> getSelectList() {
    return this.selectList;
  }

  public void setSelectList(@org.apache.thrift.annotation.Nullable java.util.List<Expression> selectList) {
    this.selectList = selectList;
  }

  public void unsetSelectList() {
    this.selectList = null;
  }

  /** Returns true if field selectList is set (has been assigned a value) and false otherwise */
  public boolean isSetSelectList() {
    return this.selectList != null;
  }

  public void setSelectListIsSet(boolean value) {
    if (!value) {
      this.selectList = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public Expression getFilterExpression() {
    return this.filterExpression;
  }

  public void setFilterExpression(@org.apache.thrift.annotation.Nullable Expression filterExpression) {
    this.filterExpression = filterExpression;
  }

  public void unsetFilterExpression() {
    this.filterExpression = null;
  }

  /** Returns true if field filterExpression is set (has been assigned a value) and false otherwise */
  public boolean isSetFilterExpression() {
    return this.filterExpression != null;
  }

  public void setFilterExpressionIsSet(boolean value) {
    if (!value) {
      this.filterExpression = null;
    }
  }

  public int getGroupByListSize() {
    return (this.groupByList == null) ? 0 : this.groupByList.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<Expression> getGroupByListIterator() {
    return (this.groupByList == null) ? null : this.groupByList.iterator();
  }

  public void addToGroupByList(Expression elem) {
    if (this.groupByList == null) {
      this.groupByList = new java.util.ArrayList<Expression>();
    }
    this.groupByList.add(elem);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.List<Expression> getGroupByList() {
    return this.groupByList;
  }

  public void setGroupByList(@org.apache.thrift.annotation.Nullable java.util.List<Expression> groupByList) {
    this.groupByList = groupByList;
  }

  public void unsetGroupByList() {
    this.groupByList = null;
  }

  /** Returns true if field groupByList is set (has been assigned a value) and false otherwise */
  public boolean isSetGroupByList() {
    return this.groupByList != null;
  }

  public void setGroupByListIsSet(boolean value) {
    if (!value) {
      this.groupByList = null;
    }
  }

  public int getOrderByListSize() {
    return (this.orderByList == null) ? 0 : this.orderByList.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<Expression> getOrderByListIterator() {
    return (this.orderByList == null) ? null : this.orderByList.iterator();
  }

  public void addToOrderByList(Expression elem) {
    if (this.orderByList == null) {
      this.orderByList = new java.util.ArrayList<Expression>();
    }
    this.orderByList.add(elem);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.List<Expression> getOrderByList() {
    return this.orderByList;
  }

  public void setOrderByList(@org.apache.thrift.annotation.Nullable java.util.List<Expression> orderByList) {
    this.orderByList = orderByList;
  }

  public void unsetOrderByList() {
    this.orderByList = null;
  }

  /** Returns true if field orderByList is set (has been assigned a value) and false otherwise */
  public boolean isSetOrderByList() {
    return this.orderByList != null;
  }

  public void setOrderByListIsSet(boolean value) {
    if (!value) {
      this.orderByList = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public Expression getHavingExpression() {
    return this.havingExpression;
  }

  public void setHavingExpression(@org.apache.thrift.annotation.Nullable Expression havingExpression) {
    this.havingExpression = havingExpression;
  }

  public void unsetHavingExpression() {
    this.havingExpression = null;
  }

  /** Returns true if field havingExpression is set (has been assigned a value) and false otherwise */
  public boolean isSetHavingExpression() {
    return this.havingExpression != null;
  }

  public void setHavingExpressionIsSet(boolean value) {
    if (!value) {
      this.havingExpression = null;
    }
  }

  public int getLimit() {
    return this.limit;
  }

  public void setLimit(int limit) {
    this.limit = limit;
    setLimitIsSet(true);
  }

  public void unsetLimit() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __LIMIT_ISSET_ID);
  }

  /** Returns true if field limit is set (has been assigned a value) and false otherwise */
  public boolean isSetLimit() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __LIMIT_ISSET_ID);
  }

  public void setLimitIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __LIMIT_ISSET_ID, value);
  }

  public int getOffset() {
    return this.offset;
  }

  public void setOffset(int offset) {
    this.offset = offset;
    setOffsetIsSet(true);
  }

  public void unsetOffset() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __OFFSET_ISSET_ID);
  }

  /** Returns true if field offset is set (has been assigned a value) and false otherwise */
  public boolean isSetOffset() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __OFFSET_ISSET_ID);
  }

  public void setOffsetIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __OFFSET_ISSET_ID, value);
  }

  public int getQueryOptionsSize() {
    return (this.queryOptions == null) ? 0 : this.queryOptions.size();
  }

  public void putToQueryOptions(java.lang.String key, java.lang.String val) {
    if (this.queryOptions == null) {
      this.queryOptions = new java.util.HashMap<java.lang.String,java.lang.String>();
    }
    this.queryOptions.put(key, val);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Map<java.lang.String,java.lang.String> getQueryOptions() {
    return this.queryOptions;
  }

  public void setQueryOptions(@org.apache.thrift.annotation.Nullable java.util.Map<java.lang.String,java.lang.String> queryOptions) {
    this.queryOptions = queryOptions;
  }

  public void unsetQueryOptions() {
    this.queryOptions = null;
  }

  /** Returns true if field queryOptions is set (has been assigned a value) and false otherwise */
  public boolean isSetQueryOptions() {
    return this.queryOptions != null;
  }

  public void setQueryOptionsIsSet(boolean value) {
    if (!value) {
      this.queryOptions = null;
    }
  }

  public boolean isExplain() {
    return this.explain;
  }

  public void setExplain(boolean explain) {
    this.explain = explain;
    setExplainIsSet(true);
  }

  public void unsetExplain() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __EXPLAIN_ISSET_ID);
  }

  /** Returns true if field explain is set (has been assigned a value) and false otherwise */
  public boolean isSetExplain() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __EXPLAIN_ISSET_ID);
  }

  public void setExplainIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __EXPLAIN_ISSET_ID, value);
  }

  public int getExpressionOverrideHintsSize() {
    return (this.expressionOverrideHints == null) ? 0 : this.expressionOverrideHints.size();
  }

  public void putToExpressionOverrideHints(Expression key, Expression val) {
    if (this.expressionOverrideHints == null) {
      this.expressionOverrideHints = new java.util.HashMap<Expression,Expression>();
    }
    this.expressionOverrideHints.put(key, val);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Map<Expression,Expression> getExpressionOverrideHints() {
    return this.expressionOverrideHints;
  }

  public void setExpressionOverrideHints(@org.apache.thrift.annotation.Nullable java.util.Map<Expression,Expression> expressionOverrideHints) {
    this.expressionOverrideHints = expressionOverrideHints;
  }

  public void unsetExpressionOverrideHints() {
    this.expressionOverrideHints = null;
  }

  /** Returns true if field expressionOverrideHints is set (has been assigned a value) and false otherwise */
  public boolean isSetExpressionOverrideHints() {
    return this.expressionOverrideHints != null;
  }

  public void setExpressionOverrideHintsIsSet(boolean value) {
    if (!value) {
      this.expressionOverrideHints = null;
    }
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case VERSION:
      if (value == null) {
        unsetVersion();
      } else {
        setVersion((java.lang.Integer)value);
      }
      break;

    case DATA_SOURCE:
      if (value == null) {
        unsetDataSource();
      } else {
        setDataSource((DataSource)value);
      }
      break;

    case SELECT_LIST:
      if (value == null) {
        unsetSelectList();
      } else {
        setSelectList((java.util.List<Expression>)value);
      }
      break;

    case FILTER_EXPRESSION:
      if (value == null) {
        unsetFilterExpression();
      } else {
        setFilterExpression((Expression)value);
      }
      break;

    case GROUP_BY_LIST:
      if (value == null) {
        unsetGroupByList();
      } else {
        setGroupByList((java.util.List<Expression>)value);
      }
      break;

    case ORDER_BY_LIST:
      if (value == null) {
        unsetOrderByList();
      } else {
        setOrderByList((java.util.List<Expression>)value);
      }
      break;

    case HAVING_EXPRESSION:
      if (value == null) {
        unsetHavingExpression();
      } else {
        setHavingExpression((Expression)value);
      }
      break;

    case LIMIT:
      if (value == null) {
        unsetLimit();
      } else {
        setLimit((java.lang.Integer)value);
      }
      break;

    case OFFSET:
      if (value == null) {
        unsetOffset();
      } else {
        setOffset((java.lang.Integer)value);
      }
      break;

    case QUERY_OPTIONS:
      if (value == null) {
        unsetQueryOptions();
      } else {
        setQueryOptions((java.util.Map<java.lang.String,java.lang.String>)value);
      }
      break;

    case EXPLAIN:
      if (value == null) {
        unsetExplain();
      } else {
        setExplain((java.lang.Boolean)value);
      }
      break;

    case EXPRESSION_OVERRIDE_HINTS:
      if (value == null) {
        unsetExpressionOverrideHints();
      } else {
        setExpressionOverrideHints((java.util.Map<Expression,Expression>)value);
      }
      break;

    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case VERSION:
      return getVersion();

    case DATA_SOURCE:
      return getDataSource();

    case SELECT_LIST:
      return getSelectList();

    case FILTER_EXPRESSION:
      return getFilterExpression();

    case GROUP_BY_LIST:
      return getGroupByList();

    case ORDER_BY_LIST:
      return getOrderByList();

    case HAVING_EXPRESSION:
      return getHavingExpression();

    case LIMIT:
      return getLimit();

    case OFFSET:
      return getOffset();

    case QUERY_OPTIONS:
      return getQueryOptions();

    case EXPLAIN:
      return isExplain();

    case EXPRESSION_OVERRIDE_HINTS:
      return getExpressionOverrideHints();

    }
    throw new java.lang.IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new java.lang.IllegalArgumentException();
    }

    switch (field) {
    case VERSION:
      return isSetVersion();
    case DATA_SOURCE:
      return isSetDataSource();
    case SELECT_LIST:
      return isSetSelectList();
    case FILTER_EXPRESSION:
      return isSetFilterExpression();
    case GROUP_BY_LIST:
      return isSetGroupByList();
    case ORDER_BY_LIST:
      return isSetOrderByList();
    case HAVING_EXPRESSION:
      return isSetHavingExpression();
    case LIMIT:
      return isSetLimit();
    case OFFSET:
      return isSetOffset();
    case QUERY_OPTIONS:
      return isSetQueryOptions();
    case EXPLAIN:
      return isSetExplain();
    case EXPRESSION_OVERRIDE_HINTS:
      return isSetExpressionOverrideHints();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that instanceof PinotQuery)
      return this.equals((PinotQuery)that);
    return false;
  }

  public boolean equals(PinotQuery that) {
    if (that == null)
      return false;
    if (this == that)
      return true;

    boolean this_present_version = true && this.isSetVersion();
    boolean that_present_version = true && that.isSetVersion();
    if (this_present_version || that_present_version) {
      if (!(this_present_version && that_present_version))
        return false;
      if (this.version != that.version)
        return false;
    }

    boolean this_present_dataSource = true && this.isSetDataSource();
    boolean that_present_dataSource = true && that.isSetDataSource();
    if (this_present_dataSource || that_present_dataSource) {
      if (!(this_present_dataSource && that_present_dataSource))
        return false;
      if (!this.dataSource.equals(that.dataSource))
        return false;
    }

    boolean this_present_selectList = true && this.isSetSelectList();
    boolean that_present_selectList = true && that.isSetSelectList();
    if (this_present_selectList || that_present_selectList) {
      if (!(this_present_selectList && that_present_selectList))
        return false;
      if (!this.selectList.equals(that.selectList))
        return false;
    }

    boolean this_present_filterExpression = true && this.isSetFilterExpression();
    boolean that_present_filterExpression = true && that.isSetFilterExpression();
    if (this_present_filterExpression || that_present_filterExpression) {
      if (!(this_present_filterExpression && that_present_filterExpression))
        return false;
      if (!this.filterExpression.equals(that.filterExpression))
        return false;
    }

    boolean this_present_groupByList = true && this.isSetGroupByList();
    boolean that_present_groupByList = true && that.isSetGroupByList();
    if (this_present_groupByList || that_present_groupByList) {
      if (!(this_present_groupByList && that_present_groupByList))
        return false;
      if (!this.groupByList.equals(that.groupByList))
        return false;
    }

    boolean this_present_orderByList = true && this.isSetOrderByList();
    boolean that_present_orderByList = true && that.isSetOrderByList();
    if (this_present_orderByList || that_present_orderByList) {
      if (!(this_present_orderByList && that_present_orderByList))
        return false;
      if (!this.orderByList.equals(that.orderByList))
        return false;
    }

    boolean this_present_havingExpression = true && this.isSetHavingExpression();
    boolean that_present_havingExpression = true && that.isSetHavingExpression();
    if (this_present_havingExpression || that_present_havingExpression) {
      if (!(this_present_havingExpression && that_present_havingExpression))
        return false;
      if (!this.havingExpression.equals(that.havingExpression))
        return false;
    }

    boolean this_present_limit = true && this.isSetLimit();
    boolean that_present_limit = true && that.isSetLimit();
    if (this_present_limit || that_present_limit) {
      if (!(this_present_limit && that_present_limit))
        return false;
      if (this.limit != that.limit)
        return false;
    }

    boolean this_present_offset = true && this.isSetOffset();
    boolean that_present_offset = true && that.isSetOffset();
    if (this_present_offset || that_present_offset) {
      if (!(this_present_offset && that_present_offset))
        return false;
      if (this.offset != that.offset)
        return false;
    }

    boolean this_present_queryOptions = true && this.isSetQueryOptions();
    boolean that_present_queryOptions = true && that.isSetQueryOptions();
    if (this_present_queryOptions || that_present_queryOptions) {
      if (!(this_present_queryOptions && that_present_queryOptions))
        return false;
      if (!this.queryOptions.equals(that.queryOptions))
        return false;
    }

    boolean this_present_explain = true && this.isSetExplain();
    boolean that_present_explain = true && that.isSetExplain();
    if (this_present_explain || that_present_explain) {
      if (!(this_present_explain && that_present_explain))
        return false;
      if (this.explain != that.explain)
        return false;
    }

    boolean this_present_expressionOverrideHints = true && this.isSetExpressionOverrideHints();
    boolean that_present_expressionOverrideHints = true && that.isSetExpressionOverrideHints();
    if (this_present_expressionOverrideHints || that_present_expressionOverrideHints) {
      if (!(this_present_expressionOverrideHints && that_present_expressionOverrideHints))
        return false;
      if (!this.expressionOverrideHints.equals(that.expressionOverrideHints))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + ((isSetVersion()) ? 131071 : 524287);
    if (isSetVersion())
      hashCode = hashCode * 8191 + version;

    hashCode = hashCode * 8191 + ((isSetDataSource()) ? 131071 : 524287);
    if (isSetDataSource())
      hashCode = hashCode * 8191 + dataSource.hashCode();

    hashCode = hashCode * 8191 + ((isSetSelectList()) ? 131071 : 524287);
    if (isSetSelectList())
      hashCode = hashCode * 8191 + selectList.hashCode();

    hashCode = hashCode * 8191 + ((isSetFilterExpression()) ? 131071 : 524287);
    if (isSetFilterExpression())
      hashCode = hashCode * 8191 + filterExpression.hashCode();

    hashCode = hashCode * 8191 + ((isSetGroupByList()) ? 131071 : 524287);
    if (isSetGroupByList())
      hashCode = hashCode * 8191 + groupByList.hashCode();

    hashCode = hashCode * 8191 + ((isSetOrderByList()) ? 131071 : 524287);
    if (isSetOrderByList())
      hashCode = hashCode * 8191 + orderByList.hashCode();

    hashCode = hashCode * 8191 + ((isSetHavingExpression()) ? 131071 : 524287);
    if (isSetHavingExpression())
      hashCode = hashCode * 8191 + havingExpression.hashCode();

    hashCode = hashCode * 8191 + ((isSetLimit()) ? 131071 : 524287);
    if (isSetLimit())
      hashCode = hashCode * 8191 + limit;

    hashCode = hashCode * 8191 + ((isSetOffset()) ? 131071 : 524287);
    if (isSetOffset())
      hashCode = hashCode * 8191 + offset;

    hashCode = hashCode * 8191 + ((isSetQueryOptions()) ? 131071 : 524287);
    if (isSetQueryOptions())
      hashCode = hashCode * 8191 + queryOptions.hashCode();

    hashCode = hashCode * 8191 + ((isSetExplain()) ? 131071 : 524287);
    if (isSetExplain())
      hashCode = hashCode * 8191 + ((explain) ? 131071 : 524287);

    hashCode = hashCode * 8191 + ((isSetExpressionOverrideHints()) ? 131071 : 524287);
    if (isSetExpressionOverrideHints())
      hashCode = hashCode * 8191 + expressionOverrideHints.hashCode();

    return hashCode;
  }

  @Override
  public int compareTo(PinotQuery other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetVersion(), other.isSetVersion());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetVersion()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.version, other.version);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetDataSource(), other.isSetDataSource());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDataSource()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dataSource, other.dataSource);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetSelectList(), other.isSetSelectList());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSelectList()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.selectList, other.selectList);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetFilterExpression(), other.isSetFilterExpression());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFilterExpression()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.filterExpression, other.filterExpression);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetGroupByList(), other.isSetGroupByList());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetGroupByList()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.groupByList, other.groupByList);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetOrderByList(), other.isSetOrderByList());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetOrderByList()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.orderByList, other.orderByList);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetHavingExpression(), other.isSetHavingExpression());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetHavingExpression()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.havingExpression, other.havingExpression);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetLimit(), other.isSetLimit());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLimit()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.limit, other.limit);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetOffset(), other.isSetOffset());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetOffset()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.offset, other.offset);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetQueryOptions(), other.isSetQueryOptions());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetQueryOptions()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryOptions, other.queryOptions);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetExplain(), other.isSetExplain());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetExplain()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.explain, other.explain);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetExpressionOverrideHints(), other.isSetExpressionOverrideHints());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetExpressionOverrideHints()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.expressionOverrideHints, other.expressionOverrideHints);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  @org.apache.thrift.annotation.Nullable
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("PinotQuery(");
    boolean first = true;

    if (isSetVersion()) {
      sb.append("version:");
      sb.append(this.version);
      first = false;
    }
    if (isSetDataSource()) {
      if (!first) sb.append(", ");
      sb.append("dataSource:");
      if (this.dataSource == null) {
        sb.append("null");
      } else {
        sb.append(this.dataSource);
      }
      first = false;
    }
    if (isSetSelectList()) {
      if (!first) sb.append(", ");
      sb.append("selectList:");
      if (this.selectList == null) {
        sb.append("null");
      } else {
        sb.append(this.selectList);
      }
      first = false;
    }
    if (isSetFilterExpression()) {
      if (!first) sb.append(", ");
      sb.append("filterExpression:");
      if (this.filterExpression == null) {
        sb.append("null");
      } else {
        sb.append(this.filterExpression);
      }
      first = false;
    }
    if (isSetGroupByList()) {
      if (!first) sb.append(", ");
      sb.append("groupByList:");
      if (this.groupByList == null) {
        sb.append("null");
      } else {
        sb.append(this.groupByList);
      }
      first = false;
    }
    if (isSetOrderByList()) {
      if (!first) sb.append(", ");
      sb.append("orderByList:");
      if (this.orderByList == null) {
        sb.append("null");
      } else {
        sb.append(this.orderByList);
      }
      first = false;
    }
    if (isSetHavingExpression()) {
      if (!first) sb.append(", ");
      sb.append("havingExpression:");
      if (this.havingExpression == null) {
        sb.append("null");
      } else {
        sb.append(this.havingExpression);
      }
      first = false;
    }
    if (isSetLimit()) {
      if (!first) sb.append(", ");
      sb.append("limit:");
      sb.append(this.limit);
      first = false;
    }
    if (isSetOffset()) {
      if (!first) sb.append(", ");
      sb.append("offset:");
      sb.append(this.offset);
      first = false;
    }
    if (isSetQueryOptions()) {
      if (!first) sb.append(", ");
      sb.append("queryOptions:");
      if (this.queryOptions == null) {
        sb.append("null");
      } else {
        sb.append(this.queryOptions);
      }
      first = false;
    }
    if (isSetExplain()) {
      if (!first) sb.append(", ");
      sb.append("explain:");
      sb.append(this.explain);
      first = false;
    }
    if (isSetExpressionOverrideHints()) {
      if (!first) sb.append(", ");
      sb.append("expressionOverrideHints:");
      if (this.expressionOverrideHints == null) {
        sb.append("null");
      } else {
        sb.append(this.expressionOverrideHints);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bitfield = 0;
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class PinotQueryStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public PinotQueryStandardScheme getScheme() {
      return new PinotQueryStandardScheme();
    }
  }

  private static class PinotQueryStandardScheme extends org.apache.thrift.scheme.StandardScheme<PinotQuery> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, PinotQuery struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // VERSION
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.version = iprot.readI32();
              struct.setVersionIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // DATA_SOURCE
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.dataSource = new DataSource();
              struct.dataSource.read(iprot);
              struct.setDataSourceIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // SELECT_LIST
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
                struct.selectList = new java.util.ArrayList<Expression>(_list0.size);
                @org.apache.thrift.annotation.Nullable Expression _elem1;
                for (int _i2 = 0; _i2 < _list0.size; ++_i2)
                {
                  _elem1 = new Expression();
                  _elem1.read(iprot);
                  struct.selectList.add(_elem1);
                }
                iprot.readListEnd();
              }
              struct.setSelectListIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // FILTER_EXPRESSION
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.filterExpression = new Expression();
              struct.filterExpression.read(iprot);
              struct.setFilterExpressionIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // GROUP_BY_LIST
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list3 = iprot.readListBegin();
                struct.groupByList = new java.util.ArrayList<Expression>(_list3.size);
                @org.apache.thrift.annotation.Nullable Expression _elem4;
                for (int _i5 = 0; _i5 < _list3.size; ++_i5)
                {
                  _elem4 = new Expression();
                  _elem4.read(iprot);
                  struct.groupByList.add(_elem4);
                }
                iprot.readListEnd();
              }
              struct.setGroupByListIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // ORDER_BY_LIST
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list6 = iprot.readListBegin();
                struct.orderByList = new java.util.ArrayList<Expression>(_list6.size);
                @org.apache.thrift.annotation.Nullable Expression _elem7;
                for (int _i8 = 0; _i8 < _list6.size; ++_i8)
                {
                  _elem7 = new Expression();
                  _elem7.read(iprot);
                  struct.orderByList.add(_elem7);
                }
                iprot.readListEnd();
              }
              struct.setOrderByListIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // HAVING_EXPRESSION
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.havingExpression = new Expression();
              struct.havingExpression.read(iprot);
              struct.setHavingExpressionIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 8: // LIMIT
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.limit = iprot.readI32();
              struct.setLimitIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 9: // OFFSET
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.offset = iprot.readI32();
              struct.setOffsetIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 11: // QUERY_OPTIONS
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map9 = iprot.readMapBegin();
                struct.queryOptions = new java.util.HashMap<java.lang.String,java.lang.String>(2*_map9.size);
                @org.apache.thrift.annotation.Nullable java.lang.String _key10;
                @org.apache.thrift.annotation.Nullable java.lang.String _val11;
                for (int _i12 = 0; _i12 < _map9.size; ++_i12)
                {
                  _key10 = iprot.readString();
                  _val11 = iprot.readString();
                  struct.queryOptions.put(_key10, _val11);
                }
                iprot.readMapEnd();
              }
              struct.setQueryOptionsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 12: // EXPLAIN
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.explain = iprot.readBool();
              struct.setExplainIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 13: // EXPRESSION_OVERRIDE_HINTS
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map13 = iprot.readMapBegin();
                struct.expressionOverrideHints = new java.util.HashMap<Expression,Expression>(2*_map13.size);
                @org.apache.thrift.annotation.Nullable Expression _key14;
                @org.apache.thrift.annotation.Nullable Expression _val15;
                for (int _i16 = 0; _i16 < _map13.size; ++_i16)
                {
                  _key14 = new Expression();
                  _key14.read(iprot);
                  _val15 = new Expression();
                  _val15.read(iprot);
                  struct.expressionOverrideHints.put(_key14, _val15);
                }
                iprot.readMapEnd();
              }
              struct.setExpressionOverrideHintsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, PinotQuery struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.isSetVersion()) {
        oprot.writeFieldBegin(VERSION_FIELD_DESC);
        oprot.writeI32(struct.version);
        oprot.writeFieldEnd();
      }
      if (struct.dataSource != null) {
        if (struct.isSetDataSource()) {
          oprot.writeFieldBegin(DATA_SOURCE_FIELD_DESC);
          struct.dataSource.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.selectList != null) {
        if (struct.isSetSelectList()) {
          oprot.writeFieldBegin(SELECT_LIST_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.selectList.size()));
            for (Expression _iter17 : struct.selectList)
            {
              _iter17.write(oprot);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.filterExpression != null) {
        if (struct.isSetFilterExpression()) {
          oprot.writeFieldBegin(FILTER_EXPRESSION_FIELD_DESC);
          struct.filterExpression.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.groupByList != null) {
        if (struct.isSetGroupByList()) {
          oprot.writeFieldBegin(GROUP_BY_LIST_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.groupByList.size()));
            for (Expression _iter18 : struct.groupByList)
            {
              _iter18.write(oprot);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.orderByList != null) {
        if (struct.isSetOrderByList()) {
          oprot.writeFieldBegin(ORDER_BY_LIST_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.orderByList.size()));
            for (Expression _iter19 : struct.orderByList)
            {
              _iter19.write(oprot);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.havingExpression != null) {
        if (struct.isSetHavingExpression()) {
          oprot.writeFieldBegin(HAVING_EXPRESSION_FIELD_DESC);
          struct.havingExpression.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetLimit()) {
        oprot.writeFieldBegin(LIMIT_FIELD_DESC);
        oprot.writeI32(struct.limit);
        oprot.writeFieldEnd();
      }
      if (struct.isSetOffset()) {
        oprot.writeFieldBegin(OFFSET_FIELD_DESC);
        oprot.writeI32(struct.offset);
        oprot.writeFieldEnd();
      }
      if (struct.queryOptions != null) {
        if (struct.isSetQueryOptions()) {
          oprot.writeFieldBegin(QUERY_OPTIONS_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.queryOptions.size()));
            for (java.util.Map.Entry<java.lang.String, java.lang.String> _iter20 : struct.queryOptions.entrySet())
            {
              oprot.writeString(_iter20.getKey());
              oprot.writeString(_iter20.getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetExplain()) {
        oprot.writeFieldBegin(EXPLAIN_FIELD_DESC);
        oprot.writeBool(struct.explain);
        oprot.writeFieldEnd();
      }
      if (struct.expressionOverrideHints != null) {
        if (struct.isSetExpressionOverrideHints()) {
          oprot.writeFieldBegin(EXPRESSION_OVERRIDE_HINTS_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRUCT, struct.expressionOverrideHints.size()));
            for (java.util.Map.Entry<Expression, Expression> _iter21 : struct.expressionOverrideHints.entrySet())
            {
              _iter21.getKey().write(oprot);
              _iter21.getValue().write(oprot);
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class PinotQueryTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public PinotQueryTupleScheme getScheme() {
      return new PinotQueryTupleScheme();
    }
  }

  private static class PinotQueryTupleScheme extends org.apache.thrift.scheme.TupleScheme<PinotQuery> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, PinotQuery struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetVersion()) {
        optionals.set(0);
      }
      if (struct.isSetDataSource()) {
        optionals.set(1);
      }
      if (struct.isSetSelectList()) {
        optionals.set(2);
      }
      if (struct.isSetFilterExpression()) {
        optionals.set(3);
      }
      if (struct.isSetGroupByList()) {
        optionals.set(4);
      }
      if (struct.isSetOrderByList()) {
        optionals.set(5);
      }
      if (struct.isSetHavingExpression()) {
        optionals.set(6);
      }
      if (struct.isSetLimit()) {
        optionals.set(7);
      }
      if (struct.isSetOffset()) {
        optionals.set(8);
      }
      if (struct.isSetQueryOptions()) {
        optionals.set(9);
      }
      if (struct.isSetExplain()) {
        optionals.set(10);
      }
      if (struct.isSetExpressionOverrideHints()) {
        optionals.set(11);
      }
      oprot.writeBitSet(optionals, 12);
      if (struct.isSetVersion()) {
        oprot.writeI32(struct.version);
      }
      if (struct.isSetDataSource()) {
        struct.dataSource.write(oprot);
      }
      if (struct.isSetSelectList()) {
        {
          oprot.writeI32(struct.selectList.size());
          for (Expression _iter22 : struct.selectList)
          {
            _iter22.write(oprot);
          }
        }
      }
      if (struct.isSetFilterExpression()) {
        struct.filterExpression.write(oprot);
      }
      if (struct.isSetGroupByList()) {
        {
          oprot.writeI32(struct.groupByList.size());
          for (Expression _iter23 : struct.groupByList)
          {
            _iter23.write(oprot);
          }
        }
      }
      if (struct.isSetOrderByList()) {
        {
          oprot.writeI32(struct.orderByList.size());
          for (Expression _iter24 : struct.orderByList)
          {
            _iter24.write(oprot);
          }
        }
      }
      if (struct.isSetHavingExpression()) {
        struct.havingExpression.write(oprot);
      }
      if (struct.isSetLimit()) {
        oprot.writeI32(struct.limit);
      }
      if (struct.isSetOffset()) {
        oprot.writeI32(struct.offset);
      }
      if (struct.isSetQueryOptions()) {
        {
          oprot.writeI32(struct.queryOptions.size());
          for (java.util.Map.Entry<java.lang.String, java.lang.String> _iter25 : struct.queryOptions.entrySet())
          {
            oprot.writeString(_iter25.getKey());
            oprot.writeString(_iter25.getValue());
          }
        }
      }
      if (struct.isSetExplain()) {
        oprot.writeBool(struct.explain);
      }
      if (struct.isSetExpressionOverrideHints()) {
        {
          oprot.writeI32(struct.expressionOverrideHints.size());
          for (java.util.Map.Entry<Expression, Expression> _iter26 : struct.expressionOverrideHints.entrySet())
          {
            _iter26.getKey().write(oprot);
            _iter26.getValue().write(oprot);
          }
        }
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, PinotQuery struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(12);
      if (incoming.get(0)) {
        struct.version = iprot.readI32();
        struct.setVersionIsSet(true);
      }
      if (incoming.get(1)) {
        struct.dataSource = new DataSource();
        struct.dataSource.read(iprot);
        struct.setDataSourceIsSet(true);
      }
      if (incoming.get(2)) {
        {
          org.apache.thrift.protocol.TList _list27 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT);
          struct.selectList = new java.util.ArrayList<Expression>(_list27.size);
          @org.apache.thrift.annotation.Nullable Expression _elem28;
          for (int _i29 = 0; _i29 < _list27.size; ++_i29)
          {
            _elem28 = new Expression();
            _elem28.read(iprot);
            struct.selectList.add(_elem28);
          }
        }
        struct.setSelectListIsSet(true);
      }
      if (incoming.get(3)) {
        struct.filterExpression = new Expression();
        struct.filterExpression.read(iprot);
        struct.setFilterExpressionIsSet(true);
      }
      if (incoming.get(4)) {
        {
          org.apache.thrift.protocol.TList _list30 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT);
          struct.groupByList = new java.util.ArrayList<Expression>(_list30.size);
          @org.apache.thrift.annotation.Nullable Expression _elem31;
          for (int _i32 = 0; _i32 < _list30.size; ++_i32)
          {
            _elem31 = new Expression();
            _elem31.read(iprot);
            struct.groupByList.add(_elem31);
          }
        }
        struct.setGroupByListIsSet(true);
      }
      if (incoming.get(5)) {
        {
          org.apache.thrift.protocol.TList _list33 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT);
          struct.orderByList = new java.util.ArrayList<Expression>(_list33.size);
          @org.apache.thrift.annotation.Nullable Expression _elem34;
          for (int _i35 = 0; _i35 < _list33.size; ++_i35)
          {
            _elem34 = new Expression();
            _elem34.read(iprot);
            struct.orderByList.add(_elem34);
          }
        }
        struct.setOrderByListIsSet(true);
      }
      if (incoming.get(6)) {
        struct.havingExpression = new Expression();
        struct.havingExpression.read(iprot);
        struct.setHavingExpressionIsSet(true);
      }
      if (incoming.get(7)) {
        struct.limit = iprot.readI32();
        struct.setLimitIsSet(true);
      }
      if (incoming.get(8)) {
        struct.offset = iprot.readI32();
        struct.setOffsetIsSet(true);
      }
      if (incoming.get(9)) {
        {
          org.apache.thrift.protocol.TMap _map36 = iprot.readMapBegin(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING); 
          struct.queryOptions = new java.util.HashMap<java.lang.String,java.lang.String>(2*_map36.size);
          @org.apache.thrift.annotation.Nullable java.lang.String _key37;
          @org.apache.thrift.annotation.Nullable java.lang.String _val38;
          for (int _i39 = 0; _i39 < _map36.size; ++_i39)
          {
            _key37 = iprot.readString();
            _val38 = iprot.readString();
            struct.queryOptions.put(_key37, _val38);
          }
        }
        struct.setQueryOptionsIsSet(true);
      }
      if (incoming.get(10)) {
        struct.explain = iprot.readBool();
        struct.setExplainIsSet(true);
      }
      if (incoming.get(11)) {
        {
          org.apache.thrift.protocol.TMap _map40 = iprot.readMapBegin(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRUCT); 
          struct.expressionOverrideHints = new java.util.HashMap<Expression,Expression>(2*_map40.size);
          @org.apache.thrift.annotation.Nullable Expression _key41;
          @org.apache.thrift.annotation.Nullable Expression _val42;
          for (int _i43 = 0; _i43 < _map40.size; ++_i43)
          {
            _key41 = new Expression();
            _key41.read(iprot);
            _val42 = new Expression();
            _val42.read(iprot);
            struct.expressionOverrideHints.put(_key41, _val42);
          }
        }
        struct.setExpressionOverrideHintsIsSet(true);
      }
    }
  }

  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
  }
}

